<?php
namespace app\admin\controller;
use app\common\controller\AdminBase;
/*人脸设备验证结果*/
class FlatVarifyRecord extends AdminBase{
	private $admin;	
	protected $beforeActionList = [
        'before_index'=>['only'=>'index'],
    ];
	function _initialize() {
		parent::_initialize();  
    }
	function index(){
		$shop_id=sp_get_current_shop_id();
		if(empty($shop_id)){
			$this->assign("shops",[]);
		}else{
			$this->assign("shops",db("Shop")->where("parent_id=(select parent_id from m_shop where id=$shop_id)")->field("shop_name,id")->select());
		}
		echo $this->fetch();
	}	
	function ajax_index(){
		$this->ajax($this->_ajax_index());
	}
	///////////////////////////////////////////////////////////////////////////////////
	/**
	 * 权限菜单
	 **/
	function before_index(){
		$auth_group=sp_get_auth_menu_3("10041015");
		$this->assign("menus",$auth_group);
	}
	
	/*获取员工数据*/
	private function _ajax_index(){
		$query=array('member_name'=>array("field" =>"member_name","operator" =>"="),
					 'member_mobile'=>array("field" =>"member_mobile","operator" =>"="),
					 'pt_name'=>array("field" =>"pt_name","operator" =>"="),
					 'pt_mobile'=>array("field" =>"pt_mobile","operator" =>"="),
					 );
		$shop_id=sp_get_current_shop_id();
		if(empty($shop_id))	{
			$shop_id=-1;
		}else{
			$shop_id=input("shop_id/d",0);
		}	 
		$draw=input("draw",0)+1;//请求时间		 
		$where_and=join(" and ",sp_get_param_sql(request()->isPost(),$query));
		$where_and.=" and shop_id=$shop_id";
		$start=input("start");
		$end=input("end");
		$where_and.=" and TO_DAYS(create_time)>=TO_DAYS('$start') and TO_DAYS(create_time)<=TO_DAYS('$end')";
		$total=db("FlatVarifyRecord")->where($where_and)->fetchsql(FALSE)->count(1);
		$list=db("FlatVarifyRecord")->where($where_and)->order($this->get_order())->limit($this->get_limit())->fetchsql(FALSE)->select();
		
		//权限
		return array('pageData'=>$list,'total'=>$total,"draw"=>$draw);
	}
}
